﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace InSafetyAirClient.GUI.Airport
{
    public partial class ListAip : UserControl
    {
        List<InSafetyAirClient.InSafetyAirService.Airport> aips = null;

        public ListAip()
        {
            InitializeComponent();
        }

        private void ListAip_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                populateList();
            }
        }

        private void populateList()
        {
            DataTable dataTable1 = new DataTable();
            dataTable1.Columns.Add("Airport Name", typeof(string));
            dataTable1.Columns.Add("City", typeof(string));
            dataTable1.Columns.Add("GMT", typeof(string));
            ServiceSingle servS = ServiceSingle.Instance;
            aips = servS.getService().GetAll(typeof(InSafetyAirClient.InSafetyAirService.Airport).Name).OfType<InSafetyAirClient.InSafetyAirService.Airport>().ToList();
            foreach (InSafetyAirService.Airport aip in aips)
            {
                dataTable1.Rows.Add(aip.name, aip.town, aip.gmt);
            }
            dataGridView1.DataSource = dataTable1;
        }
    }
}
